package com.ruoyi.web.controller.app.im.app.service;


import com.ruoyi.im.domain.UserCollection;
import com.ruoyi.im.mapper.UserCollectionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 用户收藏
 */
@Service
public class AppCollectionService {
    @Autowired(required = false)
    private UserCollectionMapper collectionMapper;//收藏mapper

    /**
     * 用户收藏
     * @param map
     * @return
     */
    public int addCollection(Map<String,String> map){
        UserCollection collection=new UserCollection();
        collection.setContent(map.get("content"));
        collection.setUserId(Long.valueOf(map.get("userId")));
        return collectionMapper.insertUserCollection(collection);
    }

    /**
     * 根据用户id收藏
     * @param userId
     * @return
     */
    public List<UserCollection> findCollectionList(String userId){
        return collectionMapper.selectCollectionListByUserId(userId);
    }


    /**
     * 取消收藏
     * @param collectionId
     * @return
     */
    public int cancelCollection(String collectionId){
        return collectionMapper.deleteUserCollectionById(Long.valueOf(collectionId));
    }

}
